const path = require('path');
const utils = require('./utils');
const setting = require('./setting');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    context: utils.resolve(),
    mode: 'development',
    entry: utils.resolve('src/entries/index.js'),
    output: {
        filename: 'bundle.js',
        path: utils.resolve('dist')
    },
    devtool: "cheap-eval-source-map",

    devServer: {
        inline: true,
        host: utils.getIP(),
        hot: true,
        open: true,
        port: setting.port,
        publicPath: setting.publicPath,
    },

    plugins: [
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin({
            title: 'Development',
            template: './src/index.html'
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin()
    ],

    module: {
        rules: [
            {
                test: /\.html$/,
                loader: 'include-loader'
            }
        ]
    },

    resolveLoader:{
        // 去哪些目录下寻找 Loader，有先后顺序之分
        modules: ['node_modules','../src/loaders/'],
    }

};